home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
comm
/
tcp
/
AutoADT1_21.lha
/
AutoADT.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1995-05-14
|
5KB
|
196 lines
/* AutoADT by Dan J. Fraser
*
* Based on Browse.DaFTP by Osma Ahvenlampi and Dan Murrell, Jr.
*
* $VER: AutoADT 1.12 (950412)
*/
/******* user-editable values ******/
temppath = 'T:' /* Where AutoADT will put its temp
* files. */
rootpath = 'UDBase0:' /* The root of yer Aminet tree */
badpath = 'UDBase0:NewFiles/' /* Where unfilable files will go */
/* PATHNAMES ---MUST--- END IN / or : */
defhostname = 'ftp.netnet.net' /* Default Aminet site */
logfile = 'LOGS:AutoADT.log' /* AutoADT's logfile */
giveup = 0 /* Give up after a failed transfer?
* 0 = no, 1 = yes */
verbosity = -1 /* Want to see more of the FTP
* output? 0 = no, 1 = yes.
* -1 = Show NO FTP output */
/******* The program's Main Magic ********/
if ~show(l, 'rexxsupport.library') then
if ~addlib('rexxsupport.library', 0, -30, 0) then
exit 50
parse arg hostname
say '
AutoADT 1.12
- by Dan Fraser'
if hostname = '' then hostname=defhostname
if ~exists( logfile ) then
if open( logit, logfile, 'W' ) then do
call writeln( logit, 'Logfile created on '||date('O')||' at '||time('C') )
call close ( logit )
end
if ~exists( "ENVARC:AutoADT" ) then
if open( fsitelist, "ENVARC:AutoADT", 'W' ) then do
call writeln( fsitelist, '0' )
call writeln( fsitelist, '' )
call close( fsitelist )
end
if open( fdate, "ENVARC:AutoADT", 'R' ) then do
lastdate = readln( fdate )
temp = readln( fdate )
call close( fdate )
end
else do
lastdate = 0
findsite = ""
use_gzip = 0
maxfind = 30
end
redir = verbosity
lg='**** AutoADT started successfully.';call dolog
pragma('D',temppath)
say 'Getting RECENT file...'
address command 'ncftp -N -V '||redir hostname||':/pub/aminet/info/adt/ADT_RECENT_7'
if ~open( frecent , "ADT_RECENT_7" , 'R' ) then do
lg = 'ERROR - Couldn''t get RECENT file';call dolog
say 'Couldn''t get RECENT file!'
exit 50
end
say 'Processing RECENT...'
recentfile=temppath||'ADT_RECENT_7'
line = readln( frecent )
if line ~= "#adt-v2" then do
call close( frecent )
return "Wrong ADT_RECENT version"
end
do while abbrev( line, "#", 1 )
line = readln( frecent )
end
newdate = lastdate
newfiles = 0
badfiles = 0
errors = 0
if list = 1 then
lastdate = 0
do while line ~= "" & ~abbrev( line, '#' )
parse var line file.date '@' file.dir '@' file.name '@' file.size '@' a '@' b '@' c '@' file.desc
if file.date > lastdate then do
if newdate <= file.date then
newdate = file.date
dot = lastpos(".", file.name)
if (dot > 0) then
file.readme = left(file.name, dot) || 'readme'
else
file.readme = file.name'.readme'
cdbad = 'cd' badpath
cdlin = 'cd' rootpath||file.dir
lin = 'ncftp -N -V '||redir hostname':/pub/aminet/'file.dir'/'file.name
quotes = 1
do while quotes < length(file.desc)+1
if substr(file.desc,quotes,1)='"' then do
file.desc=insert('*',file.desc,quotes-1)
quotes=quotes+1
end
quotes=quotes+1
end
notelin = 'filenote' file.name '"'file.desc'"'
badnote = 'filenote' badpath||file.name '"'file.desc'"'
pragma('D',badpath);
pragma('D',rootpath||file.dir);
say ' '
say 'Getting File to: '||rootpath||file.dir'/'file.name
address command lin
if ~exists( rootpath||file.dir'/'file.name ) then
if ~exists( badpath||file.name ) then do
lg = 'ERROR getting file '||file.dir||'/'||file.name;call dolog
if giveup then do
lg = 'Giving up!';call dolog
say 'Big error! I''m crapping out.'
exit(50)
end
errors=1
end; else do
badfiles=badfiles+1
lg = 'ERROR put file '||file.dir||'/'||file.name||' in '||badpath;call dolog
address command badnote
end
else do
newfiles=newfiles+1
lg = 'Got '||file.dir||'/'||file.name||' successfully.';call dolog
say 'Adding filenote: '||file.desc
address command notelin
end
end
line = readln( frecent )
end
call close( frecent )
call close( batchout )
lastdate = newdate
lg = 'Transfer completed. '||newfiles||' new files, '||badfiles||' bad.';call dolog
if errors then do
lg = 'Errors occured during the transfer.'
call dolog
end
say 'Updating config file...'
if open( fprefs, "ENVARC:AutoADT", 'W' ) then do
call writeln( fprefs, lastdate )
end
call close( fprefs )
address command 'delete '||temppath||'ADT_RECENT_7 QUIET'
exit(0)
DoLog:
if open( logit, logfile, 'A' ) then do
call writeln( logit, date('O')||' 'time('N')||' '||lg)
call close( logit )
end